<template>
<view>
<view class="container">
  <view class="servant_top">
    <image src="https://image1.sansancloud.com/xianhua/2019_7/9/17/4/27_602.jpg?x-oss-process=style/preview_120" @click.stop="showShare" mode="aspectFit" class="share_icon"></image>
    <image mode="aspectFill" :src="(servantDetail.backgroudImg&&servantDetail.backgroudImg!=0?servantDetail.backgroudImg:'https://image1.sansancloud.com/xianhua/2019_7/9/16/15/55_241.jpg?x-oss-process=style/preview_120')" class="servant_top_bg"></image>
    <view class="servant_top_info" :data-link="'chat_room.html?puid=' + servantDetail.managerPlatformUserId + '&puname=' + servantDetail.managerPlatformUserName" @click.stop="tolinkUrl">
      <image :src="servantDetail.icon" mode class="servant_head_img"></image>
      <view class="servant_name_block">
        <text class="servant_name">{{servantDetail.name}}</text>
        <view class="servant_certification" :style="'background:' + (servantDetail.renzhengStatus==1?platformSetting.defaultColor:'#ccc')" v-if="servantDetail.renzhengStatus!=-1">
          <text v-if="servantDetail.renzhengStatus==1">已认证</text>
          <text v-if="servantDetail.renzhengStatus==0">未认证</text>
        </view>
      </view>
      <view class="servant_score">
        <view class="servant_score_item" v-for="(pingfenItem, index) in servantDetail.pingfen" :key="index">
          <image src="https://image1.sansancloud.com/xianhua/2019_7/9/16/19/57_322.jpg?x-oss-process=style/preview_120" class="servant_score_item_icon"></image>
        </view>
        <text>{{servantDetail.evaluateValue}}评分</text>
      </view>
      <scroll-view scroll-x class="servant_tag_scroll_list" scroll-with-animation="true">
        <view class="servant_tag_item" v-for="(tagItem, index) in servantDetail.tagArray" :key="index">{{tagItem}}</view>
      </scroll-view>
    </view>
  </view>
  <!-- 个人介绍 -->
  <view class="servant_info_block">
    <view class="servant_info_block_title">
      <image mode="aspectFit" src="https://image1.sansancloud.com/xianhua/2019_7/9/17/36/51_263.jpg?x-oss-process=style/preview_120" class="servant_info_block_title_icon"></image>
      <text class="servant_info_block_title_text">{{properties.alias_yewuyuan||"服务员"}}介绍</text>
    </view>
    <!-- 富文本 -->
    <view class="servant_rich" v-if="servantDetail.richText">
        <rich-text-component :receiveData="articleJsonData" v-if="articleJsonData"></rich-text-component>
	</view>
    <view class="servant_rich" v-else>暂无详情介绍~</view>
  </view>
  <view class="line" :style="'border-bottom:8rpx solid ' + platformSetting.defaultColor + '55'"></view>
  <!-- 服务项目 -->
  <view class="servant_info_block" v-if="servantTypeState">
    <view class="servant_info_block_title">
      <image mode="aspectFit" src="https://image1.sansancloud.com/xianhua/2019_7/9/17/37/24_725.jpg?x-oss-process=style/preview_120" class="servant_info_block_title_icon"></image>
      <text class="servant_info_block_title_text">服务项目</text>
    </view>
    <view class="servant_server_list">
      <view class="servant_server_item" v-for="(servantTypeRelatesItem, index) in servantTypeRelatesData" :key="index" :data-index="index" :style="'background:' + platformSetting.defaultColor">
        <text class="servant_server_item_name">{{servantTypeRelatesItem.typeName}}</text>
      </view>
    </view>
  </view>
  <!-- <view class="line" :style="'background:' + platformSetting.defaultColor + '55'" v-if="servantTypeState"></view> -->
  <!-- 评价信用 -->
  <!-- <view class="servant_info_block">
    <view class="servant_info_block_title">
      <image mode="aspectFit" src="https://image1.sansancloud.com/xianhua/2019_7/9/17/37/24_727.jpg?x-oss-process=style/preview_120" class="servant_info_block_title_icon"></image>
      <text class="servant_info_block_title_text">评价信用</text>
    </view>
    <view class="servant_score_detail">
      <view class="servant_score_detail_item">
        <view class="servant_score_detail_item_left">
          <text class="servant_score_detail_item_title">咨询质量:</text>
          <view class="servant_score_detail_item_icon" v-for="(pingfenItem, index) in servantDetail.fuwuzhiliang" :key="index">
            <image src="https://image1.sansancloud.com/xianhua/2019_7/9/17/44/7_448.jpg?x-oss-process=style/preview_120" class="servant_score_detail_item_icon_img"></image>
          </view>
          <view class="servant_score_detail_item_icon" v-for="(pingfenItem, index) in 5-servantDetail.fuwuzhiliang" :key="index">
            <image src="https://image1.sansancloud.com/xianhua/2019_7/9/16/14/58_109.jpg?x-oss-process=style/preview_120" class="servant_score_detail_item_icon_img"></image>
          </view>
        </view>
        <view class="servant_score_detail_item_right">
          <text>{{servantDetail.fuwuzhiliang}}评分</text>
        </view>
      </view>
      <view class="servant_score_detail_item">
        <view class="servant_score_detail_item_left">
          <text class="servant_score_detail_item_title">服务态度:</text>
          <view class="servant_score_detail_item_icon" v-for="(pingfenItem, index) in servantDetail.fuwutaidu" :key="index">
            <image src="https://image1.sansancloud.com/xianhua/2019_7/9/17/44/7_448.jpg?x-oss-process=style/preview_120" class="servant_score_detail_item_icon_img"></image>
          </view>
          <view class="servant_score_detail_item_icon" v-for="(pingfenItem, index) in 5-servantDetail.fuwutaidu" :key="index">
            <image src="https://image1.sansancloud.com/xianhua/2019_7/9/16/14/58_109.jpg?x-oss-process=style/preview_120" class="servant_score_detail_item_icon_img"></image>
          </view>
        </view>
        <view class="servant_score_detail_item_right">
          <text>{{servantDetail.fuwutaidu}}评分</text>
        </view>
      </view>
      <view class="servant_score_detail_item">
        <view class="servant_score_detail_item_left">
          <text class="servant_score_detail_item_title">回复速度:</text>
          <view class="servant_score_detail_item_icon" v-for="(pingfenItem, index) in servantDetail.huifusudu" :key="index">
            <image src="https://image1.sansancloud.com/xianhua/2019_7/9/17/44/7_448.jpg?x-oss-process=style/preview_120" class="servant_score_detail_item_icon_img"></image>
          </view>
          <view class="servant_score_detail_item_icon" v-for="(pingfenItem, index) in 5-servantDetail.huifusudu" :key="index">
            <image src="https://image1.sansancloud.com/xianhua/2019_7/9/16/14/58_109.jpg?x-oss-process=style/preview_120" class="servant_score_detail_item_icon_img"></image>
          </view>
        </view>
        <view class="servant_score_detail_item_right">
          <text>{{servantDetail.huifusudu}}评分</text>
        </view>
      </view>
    </view>
  </view> -->
  <view class="line" :style="'border-bottom:8rpx solid ' + platformSetting.defaultColor + '55'"></view>
  <view class="servant_info_block">
    <view class="servant_info_block_title">
      <image mode="aspectFit" src="https://image1.sansancloud.com/xianhua/2019_7/9/17/37/24_725.jpg?x-oss-process=style/preview_120" class="servant_info_block_title_icon"></image>
      <text class="servant_info_block_title_text">服务评价</text>
    </view>
    <view class="servant_server_list">
       <view class="form_detail_bottom">
        <view class="comments_list">
          <view class="comments_item" v-for="(evaluationItem, index) in evaluationList" :key="index" v-if="evaluationList.length!=0">
            <image class="user_img" :src="evaluationItem.commentPlatformUserIcon"></image>
            <view class="comments_item_right">
              <text class="user_name">{{evaluationItem.commentPlatformUserName}}</text>
              <scroll-view scroll-x class="tab_scroll_list" scroll-with-animation="true" v-if="evaluationItem.tagArray">
                  <view class="tab_item" v-for="(tagItem, index) in evaluationItem.tagArray" :key="index" :style="'color:'+platformSetting.defaultColor+';border:1rpx solid'+ platformSetting.defaultColor">{{tagItem}}</view>
              </scroll-view>
              <text class="user_need">{{evaluationItem.comment}}</text>
              <view class="comments_item_bottom">
                <text class="user_time">{{evaluationItem.commentTime}}</text>
                <view class="pingfen_block">
                    <text>评分：</text>
                    <view class="star_container">
                      <view class="star">
                        <block v-if="evaluationItem.pingfen > 0"><image src="https://image1.sansancloud.com/naifen/2019_5/31/17/7/11_803.jpg?x-oss-process=style/preview_120"></image></block>
                        <block v-else><image src="https://image1.sansancloud.com/naifen/2019_5/31/17/7/11_828.jpg?x-oss-process=style/preview_120"></image></block>
                      </view>
                      <view class="star">
                        <block v-if="evaluationItem.pingfen > 1"><image src="https://image1.sansancloud.com/naifen/2019_5/31/17/7/11_803.jpg?x-oss-process=style/preview_120"></image></block>
                        <block v-else><image src="https://image1.sansancloud.com/naifen/2019_5/31/17/7/11_828.jpg?x-oss-process=style/preview_120"></image></block>
                      </view>
                      <view class="star">
                        <block v-if="evaluationItem.pingfen > 2"><image src="https://image1.sansancloud.com/naifen/2019_5/31/17/7/11_803.jpg?x-oss-process=style/preview_120"></image></block>
                        <block v-else><image src="https://image1.sansancloud.com/naifen/2019_5/31/17/7/11_828.jpg?x-oss-process=style/preview_120"></image></block>
                      </view>
                      <view class="star">
                        <block v-if="evaluationItem.pingfen > 3"><image src="https://image1.sansancloud.com/naifen/2019_5/31/17/7/11_803.jpg?x-oss-process=style/preview_120"></image></block>
                        <block v-else><image src="https://image1.sansancloud.com/naifen/2019_5/31/17/7/11_828.jpg?x-oss-process=style/preview_120"></image></block>
                      </view>
                      <view class="star">
                        <block v-if="evaluationItem.pingfen > 4"><image src="https://image1.sansancloud.com/naifen/2019_5/31/17/7/11_803.jpg?x-oss-process=style/preview_120"></image></block>
                        <block v-else><image src="https://image1.sansancloud.com/naifen/2019_5/31/17/7/11_828.jpg?x-oss-process=style/preview_120"></image></block>
                      </view>
                    </view>
                </view>
                <!-- <image class="comments_icon" :data-link="'form_reply.html?id=' + evaluationItem.id" @tap="tolinkUrl" src="https://image1.sansancloud.com/jianzhan/2019_3/13/17/6/38_907.jpg?x-oss-process=style/preview_120"></image> -->
              </view>
            </view>
          </view>
          <view class="no_item_reply" v-if="evaluationList.length==0">
            <text>还没有任何评价信息~</text>
          </view>
          <view class="more_reply" v-if="evaluationList.length!=0" @click="moreEvaluationListFun()">
            <text>查看更多评价...</text>
          </view>
        </view>
      </view>
    </view>
  </view>
  <view class="line" :style="'border-bottom:8rpx solid ' + platformSetting.defaultColor + '55'" v-if="servantDetail.commentAble==1"></view>
  <view class="servant_info_block" v-if="servantDetail.commentAble==1">
    <view class="servant_info_block_title">
      <image mode="aspectFit" src="https://image1.sansancloud.com/xianhua/2019_7/9/17/37/24_725.jpg?x-oss-process=style/preview_120" class="servant_info_block_title_icon"></image>
      <text class="servant_info_block_title_text">服务留言</text>
    </view>
    <view class="servant_server_list">
       <view class="form_detail_bottom">
        <!-- <view class='form_detail_bottom_top'>
          <view class='bottom_top_item'>
            <image class='bottom_top_item_icon' src='https://image1.sansancloud.com/jianzhan/2019_3/12/14/47/49_487.jpg?x-oss-process=style/preview_120'></image>
            <text class='bottom_top_item_text'>{{servantDetail.viewCount}}</text>
          </view>
          <view class='bottom_top_item'>
            <image class='bottom_top_item_icon' src='https://image1.sansancloud.com/jianzhan/2019_3/12/14/47/49_496.jpg?x-oss-process=style/preview_120'></image>
            <text class='bottom_top_item_text'>{{servantDetail.viewCount}}</text>
          </view>
        </view> -->
        <view class="comments_list">
          <view class="comments_item" v-for="(conmmentItem, index) in conmmentList" :key="index" v-if="conmmentList.length!=0">
            <image class="user_img" :src="conmmentItem.commentUserIcon"></image>
            <view class="comments_item_right">
              <text class="user_name">{{conmmentItem.commentUserName}}</text>
              <text class="user_need">{{conmmentItem.comment}}</text>
              <view class="other_reply_item" v-for="(reconmmentItem, index2) in conmmentItem.recomments" :key="index2" v-if="conmmentItem.length!=0">
                <text class="other_reply_name">{{reconmmentItem.commentUserName}}</text>
                <text class="interval">:</text>
                <text class="other_reply_text">{{reconmmentItem.comment}}</text>
              </view>
              <view class="more_reply" :data-link="'form_reply.html?id=' + conmmentItem.id" @tap="tolinkUrl" v-if="conmmentItem.recommentCount>3">
                <text>查看更多回复...</text>
              </view>
              <view class="comments_item_bottom">
                <text class="user_time">{{conmmentItem.commentTime}}</text>
                <image class="comments_icon" :data-link="'form_reply.html?id=' + conmmentItem.id" @tap="tolinkUrl" src="https://image1.sansancloud.com/jianzhan/2019_3/13/17/6/38_907.jpg?x-oss-process=style/preview_120"></image>
              </view>
            </view>
          </view>
          <view class="no_item_reply" v-if="conmmentList.length==0">
            <text>主人~该帖子还没有人回复哦！</text>
          </view>
        </view>
      </view>
    </view>
  </view>
</view>
<!-- 发布留言 -->
<view class="zhezhao" v-if="showCommentState&&servantDetail.commentAble==1" @tap="closeZhezhao"></view>
<view class="comments_part" v-if="servantDetail.commentAble==1&&showCommentState">
  <input class="comments_input b" focus @confirm="sendComments" @input="saveData" :value="commentValue" cursor-spacing="130" placeholder="发表评论..." maxlength="76"></input>
  <image class="comments_img_icon" @tap="sendComments" src="https://image1.sansancloud.com/jianzhan/2019_3/13/18/4/57_119.jpg?x-oss-process=style/preview_120" mode="aspectFitf"></image>
</view>
<!-- 底部按钮组 -->
<view class="bottom_btn_group" v-if="!servantTypeId||(curSelectData&&curSelectData.servantTypeBean.servantServiceType!=0)">
  <view class="bottom_btn_group_left">
    <view class="bottom_btn_group_left_item" @click.stop="focusServant">
      <image class="bottom_btn_group_left_item_icon" src="https://image1.sansancloud.com/xianhua/2019_11/11/15/52/2_748.jpg?x-oss-process=style/preview_120"></image>
      <text class="bottom_btn_group_left_item_text">关注</text>
    </view>
    <view class="bottom_btn_group_left_item" @tap="showCommentFun">
      <image class="bottom_btn_group_left_item_icon" src="https://image1.sansancloud.com/xianhua/2019_11/11/15/52/2_720.jpg?x-oss-process=style/preview_120"></image>
      <text class="bottom_btn_group_left_item_text">留言</text>
    </view>
  </view>
  <view class="bottom_btn_group_right" v-if="servantTypeId" @click.stop="submitData">
    <text class="bottom_btn_group_right_text" :style="'background:' + platformSetting.defaultColor" v-if="curSelectData.servantTypeBean.servantServiceType==1">拨打电话</text>
    <text class="bottom_btn_group_right_text" :style="'background:' + platformSetting.defaultColor" v-if="curSelectData.servantTypeBean.servantServiceType==2">预约</text>
  </view>
  <view class="bottom_btn_group_right" @click.stop="popupServantTypePage" v-else>
    <text class="bottom_btn_group_right_text" :style="'background:' + platformSetting.defaultColor">预约</text>
  </view>
</view>
<view class="popupServantTypeDetail" :animation="animationData" v-if="showType">
  <scroll-view scroll-y>
    <view class="servantTypeList">
      <view class="servantTypeItem" v-for="(servantTypeRelatesItem, index) in servantTypeRelatesData" :key="index" :data-index="index" :data-info="servantTypeRelatesItem" @click.stop="selectServantTypeFun" :style="'color:' + (curSelectIndex==index?platformSetting.defaultColor:'')">
        <text>{{servantTypeRelatesItem.typeName}}</text>
        <view><text v-if="servantTypeRelatesItem.price!=0">￥{{servantTypeRelatesItem.price}}</text><text v-else></text></view>
      </view>
    </view>
    </scroll-view>
</view>
<view v-if="showType" class="submitBtn" @click.stop="submitData" :data-link="'chat_room.html?puid=' + servantDetail.managerPlatformUserId + '&puname=' + servantDetail.managerPlatformUserName">
  <text :style="'background:' + platformSetting.defaultColor" v-if="curSelectData.servantTypeBean.servantServiceType==1">拨打电话</text>
  <text :style="'background:' + platformSetting.defaultColor" v-if="curSelectData.servantTypeBean.servantServiceType==2">预约</text>
  <text :style="'background:' + platformSetting.defaultColor" v-if="curSelectData.servantTypeBean.servantServiceType==3">立即预约</text>
  <text :style="'background:' + platformSetting.defaultColor" v-if="curSelectData.servantTypeBean.servantServiceType==4">立即购买</text>
  <text :style="'background:' + platformSetting.defaultColor" v-if="curSelectData.servantTypeBean.servantServiceType==5">立即聊天</text>
  <text :style="'background:' + platformSetting.defaultColor" v-if="curSelectData.servantTypeBean.servantServiceType==0">无操作</text>
  <text :style="'background:' + platformSetting.defaultColor" v-if="!curSelectData.servantTypeBean.servantServiceType&&curSelectData.servantTypeBean.servantServiceType!=0">请选择项目</text>
</view>
<view class="zhezhao" v-if="showType" @tap="closeZhezhao"></view>
<!-- 填写表单弹窗动画 -->
<view class="popupFormDetail" :animation="animationData" v-if="sendOptionData&&showSubmitForm">
  <view class="form_title">
    <image @click.stop="nextStepFun" class="return_select_measure_icon" src="https://image1.sansancloud.com/xianhua/2019_7/31/15/25/40_519.jpg?x-oss-process=style/preview_120"></image>
    <text>请填写以下信息</text>
    <image class="close_popup_icon" src="https://image1.sansancloud.com/xianhua/2019_7/31/15/25/40_755.jpg?x-oss-process=style/preview_120" @click.stop="closeZhezhao"></image>
  </view>
  <scroll-view scroll-y style="max-height:700rpx">
    <view v-if="sendOptionData&&showSubmitForm">
       <form-detail-component id="submitForm" :receiveData="sendOptionData" showTitle="true" showBtn="false" :userAddressCustomFormCommitId="userInfoFormCommitId" @sendDataFun="getDataFun"></form-detail-component><!-- 弹窗 -->
    </view>
  </scroll-view>
</view>
<view v-if="showSubmitForm" class="formSubmitBtn" :style="'background:' + platformSetting.defaultColor" @click.stop="submitFormData">
  <text>提交资料</text>
</view>
<!-- 分享 -->
<view class="zhezhao" v-if="showTypeTwo" @tap="showShareClose"></view>
<view class="select_share_list" :animation="animationDataTwo">
  <view class="select_share_item" v-for="(item, index) in shareTypeData" :key="index">
    <text class="select_share_name" @click.stop="showPoster" v-if="item.type=='text'">{{item.name}}</text>
    <button open-type="share" class="select_share_name" v-else>{{item.name}}</button>
  </view>
  <view class="select_share_item cancel_select_share" @click.stop="showShareClose">
    <text class="select_share_name">取消</text>
  </view>
</view>
<!-- 分时预约 -->
<view class="time_share_block" :animation="timeShareAnimationData" v-if="showDataListState">
    <view class="form_title" style="padding: 30rpx;">
      <text></text>
      <text>选择预约时间</text>
      <image class="close_popup_icon" src="https://image1.sansancloud.com/xianhua/2019_7/31/15/25/40_755.jpg?x-oss-process=style/preview_120" @click.stop="nextStepFun"></image>
    </view>
    <view class="days_list">
      <scroll-view scroll-x class="days_scroll_list" scroll-with-animation="true">
        <view class="days_item" v-for="(data, index) in nextDaysList" :key="index" :data-info="data" :data-index="index" @click.stop="selectDataFun">
          <text class="days_item_data">{{data.oneDataStr}}</text>
          <text class="days_item_week" :style="dayParams.dataIndex==index?'color:#fff;background:'+platformSetting.defaultColor:''">{{data.weekData}}</text>
          <!--  :class="[listPage.dateIndex==index?'days_item_week active':'days_item_week']" -->
        </view>
      </scroll-view>
    </view>
    <view class="venues_date_cells_list">
      <view class="venues_date_cells_item" v-for="(data, index) in venuesCellList.cells" :key="index" :data-type="(data.state?'cancel':'select')" :data-index="index" :data-info="data" :data-startSecond="data.startTimeSeconds" @click.stop="selecVenuesCellItemFun" :style="'border: 1rpx solid ' + (data.state?platformSetting.defaultColor:'#ccc') + ';background:' + (data.state?platformSetting.defaultColor+'22':'#fff')">
        <text class="venues_date_cells_time" :style="'color:' + (data.status!=1?'#999':'')">{{data.startTimeStr}}</text>
        <text class="venues_date_cells_price" v-if="data.cellPrice>0" :style="'color:' + (data.status!=1?'#999':platformSetting.defaultColor)">￥{{data.cellPrice}}</text>
        <text class="cell_tag_bg" v-if="data.cellTag" :style="'border-top: 30px solid ' + (data.status!=1?'#999':platformSetting.defaultColor) + ';'"></text>
        <text class="cell_tag_text" v-if="data.cellTag">{{data.cellTag}}</text>
      </view>
    </view>
    <view v-if="showDataListState" class="formSubmitBtn" :style="'background:' + platformSetting.defaultColor" @click.stop="confirmReserve">
      <text>确定</text>
    </view>
</view>
</view>
</template>

<script>

export default {
  data() {
    return {
      servantDetail: {},
      servantTypeRelatesData: [],
      animationData: {},
      timeShareAnimationData: {},
      //抽屉
      showType: false,
      curSelectIndex: -1,
      curSelectData: null,
      showSubmitForm: false,
      servantTypeState: false,
      servantTypeId: 0,
      showTypeTwo: false,
      animationDataTwo: null,
      showCommentState: false,
      conmmentList: [],
      recommentReturn: false,
      commentValue: '',
      shareTypeData: [{
        name: '发送给朋友',
        type: 'botton'
      }],
      params: {},
      sendOptionData: {},
      platformSetting: "",
      properties: "",
      article_article: "",
      articleJsonData:'',
      nextDaysList:[],
      showDataListState:false,
      dayParams:{dataStr:'',dataIndex:0,venuesId:0,servantId:0,servantTypeId:0},
      venuesCellList:[],
      haveVenuesDateCellsList:[],
      allPrice:0,
      evaluationList:[],
      listEvaluationPage:{
          page: 1,
          pageSize: 20,
          totalSize: 0,
          targetType:26,
          targetId: 0,
      },
    };
  },
  props: {},

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let that = this;
    console.log("======servantDetail=====", options);

    if (getApp().globalData.setting.platformSetting.id) {
      that.setData({
        platformSetting: getApp().globalData.setting.platformSetting,
        properties: getApp().globalData.properties
      });
      wx.setNavigationBarTitle({
        title: (that.properties.alias_yewuyuan || "服务员") + "详情"
      });
      console.log("======platformSetting=====", that.platformSetting);
    }

    let servantTypeState = that.servantTypeState;
    that.nextDaysList=getApp().globalData.getNextSevenDays(10,'00');
    that.$set(that.dayParams,'dataStr',that.nextDaysList[0].oneData)
    console.log('===nextSevenDays===',that.nextDaysList)
    if (options.servantTypeId) {
      servantTypeState = false;
    } else {
      servantTypeState = true;
    }

    that.setData({
      servantTypeState: servantTypeState,
      servantTypeId: options.servantTypeId
    });
    that.params = options;
    that.getServantDetail(that.params);
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {},

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    let that = this;

    if (that.recommentReturn) {
      that.getCommentData(that.allFormData.id, 1);
    }
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {},

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    let that = this;
    console.log("下拉");
    that.getServantDetail(that.params);
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {},

  /**
   * 用户点击右上角分享
   */
  onShareTimeline:function(){
    return this.shareFun()
  },
  onShareAppMessage: function (res) {
    console.log(res);
    return this.shareFun()
  },
  methods: {
    shareFun:function(){
        let that = this;
        that.showShareClose();
        console.log("======this.params======", this.params);
        let params = this.params;
        let shareName = that.servantDetail.name + "(" + that.servantDetail.tagArray + ")";
        let shareAppMessageData = getApp().globalData.shareForFx2('servant_detail', shareName, params, '', 'custom_form_commit_id');
        console.log('params:', params);
        return shareAppMessageData;
    },
    moreEvaluationListFun:function(){
        let that=this;
        console.log("==moreEvaluationListFun==",)
        if (that.listEvaluationPage.totalSize > that.listEvaluationPage.page * that.listEvaluationPage.pageSize) {
          that.listEvaluationPage.page++
          that.getEvaluationListData(that.listEvaluationPage,'upload');
        }else{
            wx.showToast({
              title: "没有更多了~",
              image: '/wxcomponents/images/icons/tip.png',
              duration: 1000
            });
        }
    },
    //获取评价数据
    getEvaluationListData:function(param){
        let that = this
        let params={}
        console.log("===params==",params,param)
        params=Object.assign({},params,param)
        let tagArray=[]
        let customIndex = getApp().globalData.AddClientUrl("/wx_find_comments_by_target.html", params);
        getApp().globalData.showToastLoading('loading', true)
        wx.request({
          url: customIndex.url,
          header: getApp().globalData.header,
          success: function (res) {
            wx.hideLoading()
            console.log(res.data)
            let data=res.data.relateObj.result;
            that.listEvaluationPage.pageSize = res.data.relateObj.pageSize
            that.listEvaluationPage.page = res.data.relateObj.curPage
            that.listEvaluationPage.totalSize = res.data.relateObj.totalSize
            let dataArr = that.evaluationList;
            console.log("===data====",data)
            if (param.page == 1) {
              dataArr = []
            }
            if (!data || data.length == 0) {
              that.setData({ evaluationList: [] })
            } else {
              if (dataArr == null) { dataArr = [] }
              dataArr = dataArr.concat(data)
              that.setData({ evaluationList: dataArr })
            }
            wx.hideLoading()
          },
          fail: function (res) {
            console.log("fail")
            wx.hideLoading()
            getApp().globalData.loadFail()
          }
        })
    },
    /* 确认预定场馆 */
    confirmReserve: function () {
      console.log("=====confirmReserve========");
      let that = this;
      let param = that.dayParams;
      let startSeconds = [];
      let haveVenuesDateCellsList = that.haveVenuesDateCellsList;
      for (let i = 0; i < haveVenuesDateCellsList.length; i++) {
        startSeconds.push(haveVenuesDateCellsList[i].startSecond);
      }
      if (startSeconds.length == 0) {
        wx.showToast({
          title: '请选择场次!',
          image: '/wxcomponents/images/icons/tip.png',
          duration: 1000
        });
        return;
      }
      console.log("======startSeconds============", startSeconds);
      let params = {
        venuesId: param.venuesId,
        venuesDateStr: param.dataStr,
        startSeconds: startSeconds.join(','),
        servantId:param.servantId,
        servantTypeId:param.servantTypeId,
        name:that.curSelectData.typeName,
      };
      var customIndex = getApp().globalData.AddClientUrl('/create_venues_order.html', params, 'post');
      getApp().globalData.showToastLoading('loading', true);
      wx.request({
        url: customIndex.url,
        data: customIndex.params,
        header: getApp().globalData.headerPost,
        method: 'POST',
        success: function (res) {
          console.log("=====confirmReserve_res======", res.data);
          let url=''
          if (res.data.errcode == 0) {
              if(res.data.relateObj.goodsAmount!=0){
                  url='edit_order.html?orderNo=' + res.data.relateObj.orderNo
              }else{
                  url = 'order_detail.html?orderNo=' + res.data.relateObj.orderNo;
              }
              that.tolinkUrl(url)
          }else{
              getApp().globalData.loadFail();
          }

          wx.hideLoading();
        },
        fail: function (res) {
          console.log("fail");
          wx.hideLoading();
          getApp().globalData.loadFail();
        },
        complete: function () {}
      });
    },
    /* 选择场馆 */
    selecVenuesCellItemFun: function (e) {
      console.log("=====selecVenuesCellItemFun========", e);
      let that = this;
      let index = e.currentTarget.dataset.index;
      let info = e.currentTarget.dataset.info;
      let type = e.currentTarget.dataset.type;
      let startSecond = e.currentTarget.dataset.startsecond;
      let haveVenuesDateCellsList = that.haveVenuesDateCellsList;
      let venuesCellList = that.venuesCellList;
      if(info.status!=1){
          return
      }
      if (haveVenuesDateCellsList.length != 0) {
        console.log("已有选择场次");
        if (type == 'cancel') {
          console.log("取消场次");
          haveVenuesDateCellsList.splice(0, 1);
          venuesCellList.cells[index].state = false;
        } else {
          console.log("选择场次");
          haveVenuesDateCellsList.splice(0, 1, {
            startSecond: startSecond,
            info: info
          });
          for(let k = 0; k < venuesCellList.cells.length; k++){
            venuesCellList.cells[k].state = false;
          }
          venuesCellList.cells[index].state = true;
        }
      } else {
        console.log("第一次选择场次");
        haveVenuesDateCellsList.splice(0, 0, {
          startSecond: startSecond,
          info: info
        });
        venuesCellList.cells[index].state = true;
      }
      console.log("=====haveVenuesDateCellsList========", haveVenuesDateCellsList);
      that.setData({
        haveVenuesDateCellsList: haveVenuesDateCellsList,
        venuesCellList: venuesCellList,
      });
    },
    selectDataFun:function(e){
        console.log("selectDataFun",e);
        let that=this;
        let index=e.currentTarget.dataset.index||e.currentTarget.dataset.index==0?e.currentTarget.dataset.index:e.detail.current;
        let itemData=that.nextDaysList[index];
        console.log("====itemData===",itemData,that.nextDaysList,index)
        that.$set(that.dayParams,'dataStr',itemData.oneData)
        that.$set(that.dayParams,'dataIndex',index)
        that.getVenuesDateCellsData(that.dayParams,function(lengthStr){
              that.showDataAnimationFun(lengthStr)
          });
    },
    /* 获取场馆日期单元 */
    getVenuesDateCellsData: function (param,callback) {
      console.log("=====getVenuesDateCellsData========", param);
      let params = {
        venuesId: param.venuesId,
        venuesDateStr: param.dataStr
      };
      var customIndex = getApp().globalData.AddClientUrl('/wx_get_venues_date_cells.html', params);
      getApp().globalData.showToastLoading('loading', true);
      var that = this;
      wx.request({
        url: customIndex.url,
        header: getApp().globalData.header,
        success: function (res) {
          console.log("=====getVenuesDateCellsData======", res.data);

          if (res.data.errcode == 0) {
            let venuesCellList = res.data.relateObj[0];

            for (let i = 0; i < venuesCellList.cells.length; i++) {
              venuesCellList.cells[i].state = false;
            }
            let lengthStr=venuesCellList.cells.length
            that.setData({
              venuesCellList: venuesCellList
            });
            if(callback){
                callback(lengthStr);
            }
            console.log("=====venuesCellList======", that.venuesCellList);
          }

          wx.hideLoading();
        },
        fail: function (res) {
          console.log("fail");
          wx.hideLoading();
          getApp().globalData.loadFail();
        },
        complete: function () {
          that.setData({
            canRefresh: true
          });
        }
      });
    },
    showCommentFun: function () {
      console.log("===showCommentFun===");
      let that = this;

      if (that.servantDetail.commentAble == 0) {
        wx.showModal({
          title: '提示',
          content: '主人~该' + (that.properties.alias_yewuyuan || "服务员") + "不允许留言！",
          success: function (res) {
            if (res.confirm) {
              console.log('用户点击确定');
            } else if (res.cancel) {
              console.log('用户点击取消');
            }
          }
        });
      }

      that.setData({
        showCommentState: true
      });
    },
    tolinkUrl: function (e) {
      let that = this;
      let linkUrl = e.currentTarget ? e.currentTarget.dataset.link : e;

      if (linkUrl.indexOf("form_reply") != -1) {
        that.recommentReturn = true;
      }

      if (that.servantDetail.commentAble == 0 && linkUrl.indexOf("chat_room") != -1) {
        return;
      }

      getApp().globalData.linkEvent(linkUrl);
    },
    saveData: function (data) {
      let that = this;
      console.log("===saveData==", data);
      that.commentValue = data.detail.value;
    },
    sendComments: function (e) {
      console.log("===sendComments==", e);
      var that = this;
      let value = e.detail && e.detail.value ? e.detail.value : that.commentValue;

      if (!value) {
        wx.showModal({
          title: '提示',
          content: '发布消息不能为空',
          success: function (res) {
            if (res.confirm) {
              console.log('用户点击确定');
            } else if (res.cancel) {
              console.log('用户点击取消');
            }
          }
        });
        return;
      }

      that.commentInput(value);
      that.setData({
        commentValue: ''
      });
      that.setData({
        showCommentState: false
      });
    },
    //添加评论
    commentInput: function (commentValue) {
      console.log("===sendComments==", commentValue);
      var that = this;
      let data = {
        servantId: that.servantDetail.id,
        comment: commentValue || that.commentValue
      };
      console.log('文本输入框: input_value :', data);
      let customIndex = getApp().globalData.AddClientUrl("/add_bbs_comments.html", data, 'post');
      wx.request({
        url: customIndex.url,
        data: customIndex.params,
        header: getApp().globalData.headerPost,
        method: 'POST',
        success: function (res) {
          console.log('==res===', res);

          if (res.data.errcode == 0) {
            that.getCommentData(that.servantDetail.id, 1);
            wx.showToast({
              title: "评论成功",
              icon: 'success',
              duration: 2000
            });
          } else {
            wx.showToast({
              title: "评论失败",
              icon: "none",
              duration: 2000
            });
          }
        }
      });
    },
    //获取评论数据
    getCommentData: function (servantId, page) {
      let that = this;
      let data = {
        servantId: servantId,
        page: page
      };
      let customIndex = getApp().globalData.AddClientUrl("/get_news_bbs_comments.html", data);
      wx.request({
        url: customIndex.url,
        data: customIndex.params,
        header: getApp().globalData.header,
        success: function (res) {
          console.log('====sssssss===', res);

          if (page == 1) {
            that.setData({
              conmmentList: res.data.relateObj.result
            });
          } else {
            console.log("====more page====");
            that.setData({
              conmmentList: that.conmmentList.concat(res.data.relateObj.result)
            });
          }
        },
        fail: function (res) {
          //获取数据失败就会进入这个方法
          wx.hideLoading();
        }
      });
    },
    focusServant: function () {
      var that = this;
      let params = {
        type: 2,
        toTargetId: that.servantDetail.id
      };
      var customIndex = getApp().globalData.AddClientUrl("/wx_set_servant_target_relate.html", params, 'post');
      getApp().globalData.showToastLoading('loading', true);
      wx.request({
        url: customIndex.url,
        data: customIndex.params,
        header: getApp().globalData.headerPost,
        method: 'POST',
        success: function (res) {
          wx.hideLoading();
          console.log("==getServantDetail===", res.data);

          if (res.data.errcode == '0') {
            let servantDetail = res.data.relateObj;
            wx.showModal({
              title: '关注服务人员',
              content: '你已关注成功~'
            });
          } else {
            wx.showModal({
              title: '失败了',
              content: '请求失败了，请下拉刷新！'
            });
          }
        }
      });
    },
    showShareClose: function () {
      this.setData({
        showTypeTwo: false
      });
      let animation = wx.createAnimation({
        duration: 400,
        timingFunction: 'ease-out'
      });
      animation.height(0).step();
      let setData = animation.export();
      this.setData({
        animationDataTwo: setData
      });
    },
    showShare: function () {
      this.setData({
        showTypeTwo: !this.showTypeTwo
      });
      let showTypeTwo = this.showTypeTwo;
      let animation = wx.createAnimation({
        duration: 400,
        timingFunction: 'ease-in-out'
      });
      console.log("=======popupFormPage==========", animation, this.showType);

      if (showTypeTwo) {
        animation.height(100).step();
      } else {
        animation.height(0).step();
      }

      this.setData({
        animationDataTwo: animation.export()
      });
    },
    nextStepFun: function () {
      let that = this;
      that.setData({
        showSubmitForm: false,
        showDataListState:false
      });
    },
    selectServantTypeFun: function (e) {
      console.log("=======selectServantTypeFun==========", e);
      let itemInfo = e.currentTarget.dataset.info;
      let index = e.currentTarget.dataset.index;
      let that = this;
      that.setData({
        curSelectIndex: index,
        curSelectData: itemInfo
      });
    },
    submitFormData: function () {
      let that = this;
      let curSelectData = that.curSelectData;
      that.selectComponent("#submitForm").formSubmit(curSelectData.servantTypeBean.refCustomFormId);
    },
    getDataFun: function (e) {
      let that = this;
      console.log("===getDataFun===", e, e.detail.formId);

      if (e.detail.result) {
        that.toPayApplyCost(e.detail.result);
      } else {
        wx.showToast({
          title: '预约成功',
          icon: 'success',
          duration: 2000
        });
        setTimeout(function () {
          that.getServantDetail(that.params);
          that.closeZhezhao();
        }, 2000);
      }
    },
    toPayApplyCost: function (result) {
      var that = this;
      let loginUser = getApp().globalData.loginUser;
      console.log(loginUser);
      let wxChatPayParam = {
        openid: '',
        orderNo: '',
        app: 3
      };
      wxChatPayParam.openid = loginUser.platformUser.miniOpenId;
      wxChatPayParam.orderNo = result.orderNo;
      console.log(wxChatPayParam);
      let customIndex = getApp().globalData.AddClientUrl("/unifined_order.html", wxChatPayParam, 'post');
      wx.request({
        url: customIndex.url,
        data: customIndex.params,
        header: getApp().globalData.headerPost,
        method: 'POST',
        success: function (res) {
          console.log(res.data);
          let PayStr = res.data;
          PayStr = '{' + PayStr + '}';
          let wechatPayStr = JSON.parse(PayStr);
          console.log(wechatPayStr);
          wx.requestPayment({
            'timeStamp': wechatPayStr.timeStamp,
            'nonceStr': wechatPayStr.nonceStr,
            'package': wechatPayStr.package,
            'signType': wechatPayStr.signType,
            'paySign': wechatPayStr.paySign,
            'success': function (res) {
              console.log('------成功--------');
              console.log(res);
              wx.showToast({
                title: '预约成功',
                icon: 'success',
                duration: 2000
              });
              that.getServantDetail(that.params);
              that.closeZhezhao();
            },
            'fail': function (res) {
              console.log('------fail--------');
              console.log(res);
              wx.showToast({
                title: '支付失败',
                image: '/wxcomponents/images/icons/tip.png',
                duration: 2000
              });
              getApp().globalData.navigateBack(2000);
            },
            'complete': function () {
              console.log('------complete--------');
              console.log(res);
            }
          });
        }
      });
    },
    showDataAnimationFun:function(lengthStr){
        let that=this;
        that.setData({
            showType:true,
            showDataListState:true
        });
        let animation = wx.createAnimation({
          duration: 400,
          timingFunction: 'ease'
        });
        let heightStr=Math.ceil(Number(lengthStr) / 4)*100+226+'rpx';
        if (that.showDataListState) {
          animation.height(heightStr).step();
        } else {
          animation.height('0').step();
        }
        setTimeout(function(){
            that.setData({
              timeShareAnimationData: animation.export()
            });
        },200)
    },
    submitData: function (e) {
      let that = this;
      console.log("===submitData===", e);
      let linkUrl = e.currentTarget.dataset.link || '';
      let curSelectData = that.curSelectData;

      if (!curSelectData) {
        wx.showModal({
          title: '提示',
          content: '主人~请选择一项服务！',
          success: function (res) {
            if (res.confirm) {
              console.log('用户点击确定');
            } else if (res.cancel) {
              console.log('用户点击取消');
            }
          }
        });
      }

      if (curSelectData && curSelectData.servantTypeBean.servantServiceType == 1) {
        getApp().globalData.calling(curSelectData.servantBean.telno);
      } else if (curSelectData && curSelectData.servantTypeBean.servantServiceType == 2) {
        this.setData({
          showType: true,
          showSubmitForm: true,
          sendOptionData: {
            customFormId: curSelectData.servantTypeBean.refCustomFormId
          }
        });
        let animation = wx.createAnimation({
          duration: 400,
          timingFunction: 'ease'
        });
        console.log("=======popupFormPage==========", animation, this.showSubmitForm);

        if (that.showSubmitForm) {
          animation.height('auto').step();
        } else {
          animation.height('0').step();
        }
        that.setData({
          animationData: animation.export()
        });
      } else if (curSelectData && curSelectData.servantTypeBean.servantServiceType == 3) {
          that.$set(that.dayParams,'venuesId',curSelectData.refVenuesId||0)
          that.$set(that.dayParams,'servantTypeId',curSelectData.servantTypeBean.id||0)
          that.getVenuesDateCellsData(that.dayParams,function(lengthStr){
              that.showDataAnimationFun(lengthStr)
          })
      }else if (curSelectData && curSelectData.servantTypeBean.servantServiceType == 4) {
        let byNowParams = {
          productId: curSelectData.servantTypeBean.servantProductId,
          itemCount: 1,
          shopId: 0,
          cartesianId: '0',
          fromSource: 'mini',
          orderType: 0,
          servantId: curSelectData.servantId
        };
        let pintuanParams = {
          pintuanCreateType: 0,
          pintuanRecordId: 0
        };

        if (!curSelectData.servantTypeBean.servantProductId) {
          wx.showModal({
            title: '提示',
            content: '该产品还未上架~',
            success: function (res) {
              if (res.confirm) {
                console.log('用户点击确定');
              } else if (res.cancel) {
                console.log('用户点击取消');
              }
            }
          });
        } else {
          getApp().globalData.createOrder(byNowParams, pintuanParams);
        }
      } else if (curSelectData && curSelectData.servantTypeBean.servantServiceType == 5) {
        getApp().globalData.linkEvent(linkUrl);
      } else if (curSelectData && curSelectData.servantTypeBean.servantServiceType == 0) {} else {}
    },
    popupServantTypePage: function () {
      console.log("=======popupServantTypePage==========");
      this.setData({
        showType: !this.showType
      });
      let showType2 = this.showType;
      let animation = wx.createAnimation({
        duration: 400,
        timingFunction: 'ease'
      });
      console.log("=======popupFormPage==========", animation, this.showType);

      if (showType2) {
        animation.height('auto').step();
      } else {
        animation.height('0').step();
      }

      this.setData({
        animationData: animation.export()
      });
    },
    closeZhezhao: function () {
      this.setData({
        showType: false,
        showSubmitForm: false,
        showCommentState: false,
        showDataListState:false
      });
      let animation = wx.createAnimation({
        duration: 400,
        timingFunction: 'ease'
      });
      animation.height('0').step();
      let setData = animation.export();
      this.setData({
        animationData: setData,
        timeShareAnimationData:setData
      });
    },
    orderServant: function (e) {
      let linkUrl = e.currentTarget.dataset.link;
      getApp().globalData.linkEvent(linkUrl);
    },
    getServantDetail: function (params) {
      var customIndex = getApp().globalData.AddClientUrl("/wx_get_servant_detail.html", params, 'post');
      var that = this;
      getApp().globalData.showToastLoading('loading', true);
      wx.request({
        url: customIndex.url,
        data: customIndex.params,
        header: getApp().globalData.headerPost,
        method: 'POST',
        success: function (res) {
          wx.hideLoading();
          console.log("==getServantDetail===", res.data);
          if (res.data.errcode == '0') {
            let servantDetail = res.data.relateObj;
            that.getServantTypeRelatesData(servantDetail.id);
            that.$set(that.dayParams,'servantId',servantDetail.id)
            that.getCommentData(servantDetail.id, 1);
            that.listEvaluationPage.targetId=servantDetail.id
            that.getEvaluationListData(that.listEvaluationPage, 'upload')
            if (servantDetail.richText) {
              let articleJsonData=servantDetail.richText;
              that.setData({
                articleJsonData:{jsonData:{content:articleJsonData}}
              });
              console.log('====articleJsonData====', that.articleJsonData);
            }
            if (servantDetail.tags && servantDetail.tags != '') {
              let tagArray = servantDetail.tags.slice(1, -1).split("][");
              servantDetail.tagArray = tagArray;
            }

            servantDetail.surname = servantDetail.name.slice(0, 1);
            that.setData({
              servantDetail: servantDetail
            });
          } else {
            wx.showModal({
              title: '失败了',
              content: '请求失败了，请下拉刷新！'
            });
          }
        }
      });
    },
    getServantTypeRelatesData: function (servantId) {
      var customIndex = getApp().globalData.AddClientUrl("/wx_find_servant_type_relates.html", {
        servantId: servantId
      }, 'post');
      var that = this; // wx.showLoading({
      //   title: 'loading'
      // })

      getApp().globalData.showToastLoading('loading', true);
      wx.request({
        url: customIndex.url,
        data: customIndex.params,
        header: getApp().globalData.headerPost,
        method: 'POST',
        success: function (res) {
          wx.hideLoading();
          console.log("==servantTypeRelatesData===", res.data);

          if (res.data.errcode == '0') {
            let curSelectData = that.curSelectData;
            let servantTypeId = that.servantTypeId;
            let curSelectIndex = that.curSelectIndex;
            let servantTypeRelatesData = res.data.relateObj.result;

            for (let i = 0; i < servantTypeRelatesData.length; i++) {
              if (servantTypeRelatesData[i].typeId == servantTypeId) {
                curSelectData = servantTypeRelatesData[i];
                curSelectIndex = i;
              }
            }

            that.setData({
              servantTypeRelatesData: servantTypeRelatesData,
              curSelectData: curSelectData,
              curSelectIndex: curSelectIndex
            });
          } else {
            wx.showModal({
              title: '失败了',
              content: '请求失败了，请下拉刷新！'
            });
          }
        }
      });
    },
    setData: function (obj) {
      let that = this;
      let keys = [];
      let val, data;
      Object.keys(obj).forEach(function (key) {
        keys = key.split('.');
        val = obj[key];
        data = that.$data;
        keys.forEach(function (key2, index) {
          if (index + 1 == keys.length) {
            that.$set(data, key2, val);
          } else {
            if (!data[key2]) {
              that.$set(data, key2, {});
            }
          }

          data = data[key2];
        });
      });
    }
  }
};
</script>
<style>
@import "./index.css";
</style>